package com.rosesoft.frame.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * @FileName EncodingFilter.java
 * @Description: 
 * @author rose
 * @version 1.0
 * <p>Company: ROSE-SOFT</p>
 * <p>Copyright: Copyright (c) 2011</p>
 */
public class EncodingFilter implements Filter {
	
	private static String ENCODING = "";

	public void destroy() {

	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		
		request.setCharacterEncoding(ENCODING);
		response.setCharacterEncoding(ENCODING);
		chain.doFilter(request, response);

	}

	public void init(FilterConfig conf) throws ServletException {
		ENCODING = conf.getInitParameter("encoding");
	}

}
